home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / dalla rivista / host contacted / jikes.lha / jikes-1.11 / src / scanner.h < prev    next >
C/C++ Source or Header  |  1999-06-22  |  3KB  |  127 lines

  1. // $Id: scanner.h,v 1.4 1999/06/22 19:17:31 shields Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #ifndef scanner_INCLUDED
  11. #define scanner_INCLUDED
  12.  
  13. #include "config.h"
  14. #include <limits.h>
  15. #include <iostream.h>
  16. #include <string.h>
  17. #include <ctype.h>
  18. #include <stdlib.h>
  19. #include <time.h>
  20. #include "code.h"
  21. #include "javadef.h"
  22. #include "javasym.h"
  23. #include "stream.h"
  24.  
  25. class Control;
  26. class FileSymbol;
  27.  
  28. //
  29. // The Scanner object
  30. //
  31. class Scanner
  32. {
  33. public:
  34.  
  35.     Scanner(Control &);
  36.  
  37.     ~Scanner() { }
  38.  
  39.     void SetUp(FileSymbol *);
  40.     void Scan(FileSymbol *);
  41.  
  42. private:
  43.     Control &control;
  44.  
  45.     LexStream* lex;
  46.     wchar_t *cursor;
  47.  
  48.     LexStream::Token *current_token;
  49.     LexStream::TokenIndex current_token_index;
  50.  
  51.     void Initialize(FileSymbol *);
  52.     void Scan();
  53.  
  54.     static int (*scan_keyword[13]) (wchar_t *p1);
  55.     static int ScanKeyword0(wchar_t *p1);
  56.     static int ScanKeyword2(wchar_t *p1);
  57.     static int ScanKeyword3(wchar_t *p1);
  58.     static int ScanKeyword4(wchar_t *p1);
  59.     static int ScanKeyword5(wchar_t *p1);
  60.     static int ScanKeyword6(wchar_t *p1);
  61.     static int ScanKeyword7(wchar_t *p1);
  62.     static int ScanKeyword8(wchar_t *p1);
  63.     static int ScanKeyword9(wchar_t *p1);
  64.     static int ScanKeyword10(wchar_t *p1);
  65.     static int ScanKeyword12(wchar_t *p1);
  66.  
  67.     inline void CheckOctalLiteral(wchar_t *, wchar_t *);
  68.     inline void SkipSpaces();
  69.     void ScanSlashComment();
  70.     void ScanStarComment();
  71.  
  72.     class BraceStack
  73.     {
  74.     public:
  75.         void Push(LexStream::TokenIndex brace) { table.Next() = brace; }
  76.         void Pop()                             { if (table.Length() > 0) table.Reset(table.Length() - 1); }
  77.         int  Size()                            { return table.Length(); }
  78.         LexStream::TokenIndex Top()            { return (table.Length() > 0 ? table[table.Length() - 1] : 0); }
  79.  
  80.     private:
  81.         Tuple<LexStream::TokenIndex> table;
  82.     } brace_stack;
  83.  
  84.     void (Scanner::*classify_token[128 + 1])();
  85.  
  86.     void ClassifyCharLiteral();
  87.     void ClassifyStringLiteral();
  88.     void ClassifyIdOrKeyword();
  89.     void ClassifyId();
  90.     void ClassifyNumericLiteral();
  91.     void ClassifyColon();
  92.     void ClassifyPlus();
  93.     void ClassifyMinus();
  94.     void ClassifyStar();
  95.     void ClassifyDocComment();
  96.     void ClassifySlash();
  97.     void ClassifyLess();
  98.     void ClassifyGreater();
  99.     void ClassifyAnd();
  100.     void ClassifyOr();
  101.     void ClassifyXor();
  102.     void ClassifyNot();
  103.     void ClassifyEqual();
  104.     void ClassifyMod();
  105.     void ClassifyPeriod();
  106.     void ClassifySemicolon();
  107.     void ClassifyComma();
  108.     void ClassifyLbrace();
  109.     void ClassifyRbrace();
  110.     void ClassifyLparen();
  111.     void ClassifyRparen();
  112.     void ClassifyLbracket();
  113.     void ClassifyRbracket();
  114.     void ClassifyComplement();
  115.     void ClassifyPound();
  116.     void ClassifyBadToken();
  117.     void ClassifyQuestion();
  118.     void ClassifyEof();
  119.  
  120.     void ClassifyNonAsciiUnicode();
  121. };
  122.  
  123. #endif
  124.  
  125.  
  126.  
  127.